<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Insert title here</title>
        <script type="text/javascript">
        	function checkzip(zip){
				var val=zip.value;
				if(val.length==0){
					alert("kong");
					return false;
				}
				//val=val.replace("-","");//替换第一个'-'符号
				val=val.replace(/-/g,"");//替换所有的'-'符号
				val=val.replace(/j/gi,"k");//替换所有的j,大小写
				alert(val);
				if(val.length!=5 && val.length!=9){
					alert("length invalid");
					return false;
				}
				for(var i=0;i<val.length;i++){
					if(val.charAt(i)<'0' || val.charAt(i)>'9'){
						alert("char["+(i+1)+"] invalid");
						return false;
					}
				}
				return true;
			}
        	function checkradio(form){
				var isEmpty=false;
				var buttons=form.group1;
				for(var i=0;i<buttons.length;i++){
					if(buttons[i].checked){
						isEmpty=true;
					}
				}
				if(!isEmpty)alert("radio empty");
				return isEmpty;
			}
			function pwd11(pwdobj1){
				if (pwdobj1.value.length < 6) {
					alert("must >= 6 ");
					pwdobj1.focus();
				}
			}
			function pwd22(pwdobj2){
				var succ= checkpwd(document.myForm.pwd1.value,pwdobj2.value);
				if(!succ){
					pwdobj2.value="";
					pwdobj2.focus();
				}
			}
			function checkpwd(pawd1,pawd2){
				if(pawd1!=pawd2){
					alert("pwd invalid");
					return false;
				}
				return true;
			}
        </script>
    </head>
    <body>
    	<form action="radio.html" name="myForm" onsubmit="return checkradio(this);">
    		zip:<input name="mytext" onblur="checkzip(this);"></input>
			<br>
			radio:<input type="radio" value="1" name="group1"/>1&nbsp;
			<input type="radio" value="2" name="group1"/>2&nbsp;
			<input type="radio" value="3" name="group1"/>3&nbsp;
			<br>
			password:<input type="password" name="pwd1" onblur="pwd11(this);"/><br>
			password again:<input type="password" name="pwd2" onfocus="pwd11(document.myForm.pwd1);" onblur="pwd22(this);"/>
			<br><input type="submit"/>
    	</form>
    </body>
</html>
